@using SDK.Common.Ports

<div class="mud-full-width mb-4" style="min-height: 337px; max-height: 337px">
    <MudBadge Content="@(_values.Count())" Color="Color.Secondary">
        <MudText>@Port.Name</MudText>
    </MudBadge>
    <div class="mud-full-width overflow-scroll" style="min-height: 270px; max-height: 270px">
        <MudList Class="py-0" Dense>
            @for (int i = 0; i < _values.Count; i++)
            {
                var index = i;
                <MudListItem Class="flow-input-body px-0 py-0">
                    <MudStack Row>
                        @switch (Port.Brand)
                        {
                            case PortBrand.StringCollection:
                                <StringInput PortBrand="Port.Brand" Value="@_values[index]" CollectionIndex="index"
                                            ValueChanged="InputValueChanged" Disabled="@(Port.IsLinkConvertable || Disabled)" />
                                break;
                            case PortBrand.NumericCollection:
                                <NumericInput PortBrand="Port.Brand" Value="@_values[index]" CollectionIndex="index"
                                            ValueChanged="InputValueChanged" Disabled="@(Port.IsLinkConvertable || Disabled)" />
                                break;
                            case PortBrand.RectangleCollection:
                                <RectangleInput PortBrand="Port.Brand" Value="@_values[index]" CollectionIndex="index"
                                            ValueChanged="InputValueChanged" Disabled="@(Port.IsLinkConvertable || Disabled)" />
                                break;
                            default:
                                break;
                        }
                        <MudBadge Content="index" Color="Color.Info" Origin="Origin.CenterLeft">
                            <MudTooltip Text="Remove item">
                                <MudIconButton Icon="@Icons.Material.Filled.Remove" Color="Color.Error" Disabled="@(Port.IsLinkConvertable || Disabled)" OnClick="@(() => RemoveItemClicked(index))" />
                            </MudTooltip>
                        </MudBadge>
                    </MudStack>
                </MudListItem>
            }
        </MudList>
    </div>
    <MudButton StartIcon="@Icons.Material.Filled.AddBox" Class="mud-full-width" Color="Color.Default"
        Variant="Variant.Filled" DisableElevation="true" Disabled="@(Port.IsLinkConvertable || Disabled)"
        OnClick="AddItemClicked">Item</MudButton>
</div>
